package top.italks.demo.mapper;

import org.apache.ibatis.annotations.*;
import top.italks.demo.entity.HREntity;

import java.util.ArrayList;

/**
 * <p>
 * private int hrId;
 * private String hrMobile;
 * private String hrPassword;
 * private String hrName;
 * private String hrEmail;
 * private String description;
 * private int departmentId;
 * </P>
 */
@Mapper
public interface HRMapper {
    /**
     * <p>`hrId` int(11) NOT NULL AUTO_INCREMENT,
     * `hrMobile` varchar(11) NOT NULL,
     * `hrPassword` varchar(500) NOT NULL,
     * `hrName` varchar(50) DEFAULT NULL,
     * `hrEmail` varchar(50) DEFAULT NULL,
     * `description` longtext,
     * `departmentId` int(11) NOT NULL,</p>
     */

    @Select("select * from hr")
    ArrayList<HREntity> listHR();

    @Select("select * from hr where hrId = #{hrId}")
    HREntity getHR(@Param("hrId") int hrId);

    @Select("select COUNT(*) from hr")
    int getHRSize();

    @Update("update hr set hrName=#{hrName}, hrEmail=#{hrEmail}, description=#{description}, departmentId=#{departmentId}, " +
            "memberValidity=#{memberValidity}, remainingCount=#{remainingCount} where hrId = #{hrId}")
    int updateHR(HREntity hrEntity);

    @Insert("insert into hr(hrMobile,hrPassword,hrName,hrEmail,description,departmentId,memberValidity,remainingCount) " +
            "values(#{hrMobile},#{hrPassword},#{hrName},#{hrEmail},#{description},#{departmentId},#{memberValidity},#{remainingCount})")
    int saveHR(HREntity hrEntity);

    @Select("select * from hr where hrMobile = #{mobile} limit 1")
    HREntity getHRByMobile(@Param("mobile") String mobile);

}
